package priv.pront.code.robot.roboCom_uni;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-07-06 14:03
 */
public class P1093_奖学金 {
    static StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static int n;
    static List<Info> list = new ArrayList<>();

    public static class Info {
        public int chinese;
        public int math;
        public int english;
        public int no;

        public  Info(int no, int chinese, int math, int english) {
            this.no = no;
            this.chinese = chinese;
            this.math = math;
            this.english = english;
        }

        public static class Com implements Comparator<Info>{
            @Override
            public int compare(Info o1, Info o2) {
                int a = o1.chinese + o1.math + o1.english;
                int b = o2.chinese + o2.math + o2.english;
                if(a != b){
                    return a - b;
                }else if(o1.chinese != o2.chinese){
                    return o1.chinese - o2.chinese;
                }else{
                    return o1.no - o2.no;
                }
            }
        }

    }
    public static void main(String[] args) throws IOException {
        st.nextToken();
        n = (int) st.nval;
        for (int i = 1; i <= n; i++) {
            st.nextToken();
            int a = (int) st.nval;
            st.nextToken();
            int b = (int) st.nval;
            st.nextToken();
            int c = (int) st.nval;
            list.add(new Info(i, a, b, c));
        }
        list.sort(new Info.Com());
        for (int i = list.size() - 1; i >= list.size() - 5; i--) {
            Info cur = list.get(i);
            int score = cur.chinese + cur.math + cur.english;
            System.out.println(cur.no + " " + score);

        }

    }
}
